<script>
import {data} from "autoprefixer";

export default {
  methods: {
    del() {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },

    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.pageable.pagesize=val
      this.findCar()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.pageable.currentpage=val
      this.findCar()
    },
    findCar(){
      this.$axios.get('Admincar/findAllCar',{
        params:{
          page:this.pageable.currentpage,
          limit:this.pageable.pagesize
        }
      }).then(data=>{
        this.car=data.data.data.records
        this.pageable.total=data.data.data.total
        // console.log(this.pageable.total)
        // console.log(data.data.data.total)
      })
    },
    handleClick(row) {
       this.$router.push({path:'/updatecar',query:{cid:row.carId}})
    }
  },
  mounted() {
    this.findCar()
  },
  data() {
    return {
      pageable:{
        currentpage:1,
        pagesizes:[5,6,7,8],
        pagesize:5,
        total:''
      },
      car: [{
      }]
    }
  },
}

</script>

<template>
  <div>
    <el-table
      :data="car"
      border
      style="width: 100%">
      <el-table-column
        prop="carName"
        label="车辆名称"
        width="150"
      >
      </el-table-column>
      <el-table-column
        prop="carStarttime"
        label="首发时间"
        width="150">
      </el-table-column>
      <el-table-column
        prop="carEndtime"
        label="到达时间"
        width="150">
      </el-table-column>
      <el-table-column
        prop="carStartaddr"
        label="首发城市"
        width="120">
      </el-table-column>
      <el-table-column
        prop="carEndaddr"
        label="到达城市"
        width="120">
      </el-table-column>
      <el-table-column
        prop="carFirst"
        label="一等座数量"
        width="120">
      </el-table-column>
      <el-table-column
        prop="carSec"
        label="二等座数量"
        width="120">
      </el-table-column>
      <el-table-column
        prop="carNo"
        label="站票数量"
        width="120">
      </el-table-column>
      <el-table-column
        prop="carPrice"
        label="价钱"
        width="120">
      </el-table-column>
      <el-table-column
        prop="carInfo"
        label="车辆信息"
        width="120">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button type="primary" @click="handleClick(scope.row)" size="small">查看</el-button><br>
          <el-button type="success" @click="del" size="small">删除</el-button>
<!--          <el-button @click="handleClick(scope.row)" type="text" size="small"></el-button>-->
<!--          <el-button type="text" size="small"></el-button>-->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page=pageable.currentpage
      :page-sizes=pageable.pagesizes
      :page-size=pageable.pagesize
      layout="total, sizes, prev, pager, next, jumper"
      :total=pageable.total
    >
    </el-pagination>

  </div>

</template>

<style>
.el-table__header{
  width: 120px;
}


</style>
